package model;


import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import java.util.Map;

import javax.imageio.ImageIO;

public class ImageStore {
	
	private Map<String, BufferedImage> store;
	
	public ImageStore() {
		store = new Hashtable<String, BufferedImage>();
	}
	
	public boolean hasImage(String fileName) {
		return this.store.containsKey(fileName);
	}
	
	public BufferedImage getImage(String fileName) {
		return this.store.get(fileName);
	}
	
	public void putImage(String fileName, BufferedImage image) {
		if(image != null)
		{
			this.store.put(fileName, image);
		}
	}
	
	public void loadImage(String fileName) throws IOException {
		File imageFile = new File(fileName);
		
		if(imageFile.exists())
		{
			BufferedImage image = ImageIO.read(imageFile);
			this.putImage(fileName, image);
		}
	}
}
